home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / DJGPP / low.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  2KB  |  80 lines

  1. /* --------------------------------- low.c ---------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Low level componnents for grasm/line.
  8.  *
  9.  * SetActiveBase (Ulong b)
  10.  * SetVisualBase (Ulong b)
  11.  * ScrClear (int x, int y, int sizex, int sizey, Uint color)
  12. */
  13.  
  14. #include "fly.h"
  15. #include "grdj.h"
  16.  
  17. #include <graphics.h>
  18. #include <pc.h>
  19. #include <dos.h>
  20.  
  21.  
  22. static char    BPTR *VideoBase = VGA_PAGE;
  23. static Ulong    VisualBase = 0;
  24. static Uint    xbytes = 0;
  25.  
  26.  
  27. extern void FAR
  28. SetActiveBase (Ulong b)
  29. {
  30.     bSetActive (VideoBase + b);
  31. }
  32.  
  33. extern void FAR
  34. SetVisualBase (Ulong base)        /* t4k/VBE specific!!!!!!!!!!!!!!! */
  35. {
  36.     int        i;
  37.     Ulong        flags;
  38.     union REGS    regs;
  39.  
  40.     if (base == VisualBase)
  41.         return;
  42.  
  43.     switch (Gr->flags & GR_TYPES) {
  44.     case GR_TYPE_T4K:
  45.         flags = Sys->Disable ();
  46.         outportb (0x3d4, 0x0d);    /* start base low */
  47.         outportb (0x3d5, (int)((base>>2)&0x00ff));
  48.  
  49.         outportb (0x3d4, 0x0c);    /* start base high */
  50.         outportb (0x3d5, (int)((base>>10)&0x00ff));
  51.  
  52.         outportb (0x3d4, 0x33);    /* start base very high */
  53.         i = inportb (0x3d5);
  54.         outportb (0x3d5, (i&~3)|(int)((base>>18)&3));
  55.         Sys->Enable (flags);
  56.         break;
  57.     case GR_TYPE_VESA:
  58.         regs.x.ax = 0x4F07;
  59.         regs.x.bx = 0;
  60.         regs.x.dx = base / xbytes;
  61.         regs.x.cx = base - regs.x.dx * (long)xbytes;
  62.         int86 (0x10, ®s, ®s);
  63.         break;
  64.     default:
  65.         /* oops! */
  66.         break;
  67.     }
  68.     VisualBase = base;
  69. }
  70.  
  71. extern void FAR
  72. InitGr (int mode, int sizex, int sizey)
  73. {
  74.     GrSetMode (mode, sizex, sizey);
  75.     xbytes = GrMaxX () + 1;
  76.     bSetSize (xbytes, GrMaxY () + 1, xbytes);
  77.     bSetActive (VideoBase);
  78.     VisualBase = 0;
  79. }
  80.